<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 *
 * 创建时间：2021-10-09 09:16:17
 *
 * 项目：/levmodules  -  $  - levModulesModelHelper.php
 *
 * 作者：{{AUTO GENERATE}}
 */

//此文件使用程序自动生成，下次生成时【不会】覆盖。
//在这里可以补充、完善你的程序逻辑

namespace modules\levmodules\table\lev_modules;

use Lev;
use lev\helpers\cacheFileHelpers;
use lev\helpers\ModulesHelper;
use modules\levmodules\controllers\AdminModulesController;
use modules\levmodules\helpers\levmodulesCacheFileHelper;
use modules\levmodules\helpers\levmodulesSetHelper;
use modules\levmodules\table\form\Form_lev_modules\Form_lev_modules;

!defined('INLEV') && exit('Access Denied LEV');

class BaseLevModulesModelMiddle extends BaseLevModulesModel
{

    /**
     * @param $adminop
     * @return array|null
     *
     * @see ModulesHelper::setField()
     */
    public static function adminop($adminop)
    {
        //return parent::adminop($adminop); // TODO: Change the autogenerated stub
        return ModulesHelper::adminop($adminop);
    }

    public static function setFormSettings($settings, $result = [])
    {
        empty($result['identifier']) || $_GET['#iden'] = $result['identifier'];//传递给字段设置项 levmodulesSetHelper::settableName()
        return parent::setFormSettings($settings, $result); // TODO: Change the autogenerated stub
    }

    /**
     * 压缩包配置
     *
        'iden'       => $iden,
        'classdir'   => false,
        'addLev'     => Lev::stripTags(Lev::GPv('addlev')),
        'unFiles'    => $unfiles,
        'replaces'   => $replaces,
        'updateDesc' => $updateDesc,
     * @param $iden
     * @param null $value
     * @return bool|mixed|string
     *
     * @see AdminModulesController::actionAjaxBatchZip()
     */
    public static function cacheZipConfig($iden, $value = null) {
        $ckey = 'do_zip_config/'.$iden.'/1';
        if ($value !== null) {
            return cacheFileHelpers::setc($ckey, $value);
        }
        $re = cacheFileHelpers::getc($ckey, false);
        if (!$re && !is_file(__DIR__ . '/.child.txt')) {
            $re = levmodulesCacheFileHelper::getc($ckey, false);
            if ($re) {
                $re = static::replacesWebroot($re);
                cacheFileHelpers::setc($ckey, $re);
            }
        }
        return $re;
    }
    public static function replacesWebroot($re) {
        $webroot = Lev::$aliases['@modules'];
        $zipm = dirname(levmodulesSetHelper::zipMdir());
        if ($webroot != $zipm) {
            $unfiles = $re['unFiles'];
            foreach ($unfiles as $k => $v) {
                $xk = str_replace($zipm, $webroot, $k);
                $res[$xk] = $v;
            }
            isset($res) && $re['unFiles'] = $res;
        }
        return $re;
    }

}


class levModulesModelHelper extends BaseLevModulesModelMiddle {

    public static function headerHtm()
    {
        //return parent::headerHtm(); // TODO: Change the autogenerated stub
        return '<tips class="gray inblk scale8">自定义headerHtm：文件位置：'.__DIR__ . '/levModulesModelHelper.php'.'</tips>';
    }

    public static function footerHtm()
    {
        //return parent::footerHtm(); // TODO: Change the autogenerated stub
        return '<tips class="gray inblk scale8">自定义footerHtm</tips>';
    }

    public static function footerFormInnerHtm()
    {
        //return parent::footerFormInnerHtm(); // TODO: Change the autogenerated stub
        return '<tips class="gray inblk scale8">自定义footerFormInnerHtm</tips>';
    }

}